<?

class ArticlesEditor {
	
	public $exists = false;
	
	function ArticlesEditor(){
		return $this;
	}
	
	public function add ($title, $description, $page_id, $bigImg){
		db_connect();
		global $tables, $a;
		
		$sql = "INSERT INTO ".$tables['articles']." SET 		 art_type = '1', 
  	 	 				 							 		 	 art_title = '".$title."',
																 art_descr = '".$description."',
		 	 				 							 		 art_content = '',  
																 art_date = NOW(),
																 art_time = NOW(),
																 art_page_id = '".$page_id."',
																 art_author_id = '1',
																 art_nomera ='',
																 art_status='0',
																 art_image_url='',
																 art_image_big_url='".$bigImg."',
																 art_image_thumb_url='',
																 art_keywords=''";
	
		//echo $sql;
		$result = mysql_query($sql) or die(mysql_error());		

	
	}
	
	public function existsImg($path){
		db_connect();
		global $tables, $a;
		
		$sql = "SELECT art_image_big_url FROM ".$tables['articles']." where art_image_big_url='".$path."' and (art_status='1' OR art_status='0')";
		$result = mysql_query($sql) or die(mysql_error());
		
		if($row =  mysql_fetch_array($result, MYSQL_ASSOC)){
			$this->exists = true;
		} else {
			$this->exists = false;
		}
		
		mysql_free_result($result);

	}
}

?>